package it.asvp.asvp_portal.data.entity.member;


import static javax.persistence.GenerationType.IDENTITY;
import it.asvp.asvp_portal.data.entity.domain.BaseEntity;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

@SuppressWarnings("serial")
@Entity
@Table(name = "member_account_update", catalog = "asvp_db", uniqueConstraints = @UniqueConstraint(columnNames = {
		"id_member", "update_year" }))
public class MemberAccountUpdate extends BaseEntity {

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	private Long id;
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "id_member", nullable = false)
	private Member member;
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "id_councilor", nullable = false)
	private Member councilor;
	
	@Column(name = "update_year", nullable = false)
	private int updateYear;
	
	public MemberAccountUpdate() {
	}

	public MemberAccountUpdate(Member member,
			Member councilor, Date lastUpdate, Date createdOn,int updateYear) {
		this.member = member;
		this.councilor = councilor;
		this.lastUpdate = lastUpdate;
		this.createdOn = createdOn;
		this.updateYear=updateYear;
	}

	
	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Member getMember() {
		return member;
	}

	public void setMember(Member member) {
		this.member = member;
	}

	public Member getCouncilor() {
		return councilor;
	}

	public void setCouncilor(Member councilor) {
		this.councilor = councilor;
	}

	@Column(name = "update_year", nullable = false)
	public int getUpdateYear() {
		return this.updateYear;
	}

	public void setUpdateYear(int updateYear) {
		this.updateYear = updateYear;
	}

}
